﻿@using NewLife.Common;
@using NewLife.Model;
@using XCode.Membership;
@using NewLife.Cube;
@using XCode;
@using NewLife.Cube.ViewModels;

@{
    var menu = ViewBag.Menu as IMenu;

    var user = ViewBag.User as IUser ?? ManageProvider.User;
    var fact = ManageProvider.Menu;
    var menus = fact.Root.Childs;
    if (user?.Role != null)
    {
        menus = fact.GetMySubMenus(fact.Root.ID, user, true);
    }
}

<!-- 左侧菜单 -->
<div class="app-sidebar-menu overflow-hidden flex-column-fluid">
    <div id="kt_app_sidebar_menu_wrapper" class="app-sidebar-wrapper">
        <div id="kt_app_sidebar_menu_scroll" class="scroll-y my-5 mx-3" 
            data-kt-scroll="true" 
            data-kt-scroll-activate="true" 
            data-kt-scroll-height="auto" 
            data-kt-scroll-dependencies="#kt_app_sidebar_logo, #kt_app_sidebar_footer" 
            data-kt-scroll-wrappers="#kt_app_sidebar_menu" 
            data-kt-scroll-offset="5px" 
            data-kt-scroll-save-state="true">
            <div id="#kt_app_sidebar_menu" class="menu menu-column menu-rounded menu-sub-indention fw-semibold px-3" data-kt-menu="true" data-kt-menu-expand="false">
                <div class="menu-item">
                    <a class="menu-link" href="@NewLife.Cube.CubeSetting.Current.StartPage">
                        <span class="menu-icon">
                            <span class="far fa-tv fs-3 text-gray-700"></span>
                        </span>
                        <span class="menu-title fs-4">系统首页</span>
                    </a>
                </div>
                <div class="menu-item">
                    <div class="menu-content">
                        <div class="separator mx-1"></div>
                    </div>
                </div>

                @if (menu != null)
                {
                    foreach (IMenu item in menus)
                    {
                        if (item.ParentID == 0)
                        {
                            @await Html.PartialAsync("_Layout_Aside_MenuItem", new ValueTuple<IMenu, IMenu>(menu, item))
                        }
                    }
                }
                <!-- <div class="menu-item">
                    <div class="menu-content">
                        <div class="separator mx-1 my-4"></div>
                    </div>
                </div> -->
                <div class="menu-item">
                </div>
            </div>

        </div>
    </div>
</div>